package com.czy.booktest02.demos.api.v1;

import com.czy.booktest02.demos.common.dtos.ResponseResult;
import com.czy.booktest02.demos.pojo.dto.OrderDto;
import com.czy.booktest02.demos.pojo.dto.OrderIdDto;
import com.czy.booktest02.demos.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    OrderService orderService;

    @PostMapping("/commitOrder")
    public ResponseResult commitOrder(@RequestBody OrderDto orderDto){
        return orderService.commitOrder(orderDto);
    }

    /**
     * 显示订单
     */
    @GetMapping("/showOrder")
    public ResponseResult showOrder(){
        return orderService.showOrder();
    }

    /**
     * 订单发货
     */
    @PostMapping("/sendOrder")
    public ResponseResult sendOrder(@RequestParam("id") int id){
        return orderService.sendOrder(id);
    }

    /**
     * 显示订单详情
     */
    @PostMapping("/checkOrderDetail")
    public ResponseResult checkOrderDetail(@RequestBody OrderIdDto orderIdDto){
        return orderService.checkOrderDetail(orderIdDto.getId());
    }

}
